Only warn once if inhibit-related dbus calls fail
authorMatthias Clasen <mclasen@redhat.com>
Mon, 3 Nov 2014 05:48:42 +0000 (00:48 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 3 Nov 2014 05:48:42 +0000 (00:48 -0500)
No need to spam about it.

https://bugzilla.gnome.org/show_bug.cgi?id=734140

gtk/gtkapplication-dbus.c

index 45136b0d86240a88d0c4d888c519391abd35d7cc..0c454478ae159f9b9a56ecce9aa52c48eb38a823 100644 (file)
@@ -334,6 +334,7 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl         *impl,
   GVariant *res;
   GError *error = NULL;
   guint cookie;
+  static gboolean warned = FALSE;
 
   if (dbus->sm_proxy == NULL)
     return 0;
@@ -352,7 +353,11 @@ gtk_application_impl_dbus_inhibit (GtkApplicationImpl         *impl,
 
  if (error)
     {
-      g_warning ("Calling Inhibit failed: %s", error->message);
+      if (!warned)
+        {
+          g_warning ("Calling Inhibit failed: %s", error->message);
+          warned = TRUE;
+        }
       g_error_free (error);
       return 0;
     }
@@ -390,6 +395,7 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl         *impl,
   GVariant *res;
   GError *error = NULL;
   gboolean inhibited;
+  static gboolean warned = FALSE;
 
   if (dbus->sm_proxy == NULL)
     return FALSE;
@@ -403,7 +409,11 @@ gtk_application_impl_dbus_is_inhibited (GtkApplicationImpl         *impl,
                                 &error);
   if (error)
     {
-      g_warning ("Calling IsInhibited failed: %s", error->message);
+      if (!warned)
+        {
+          g_warning ("Calling IsInhibited failed: %s", error->message);
+          warned = TRUE;
+        }
       g_error_free (error);
       return FALSE;
     }